package com.shxt.framework.rbac.menu.web;

import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.shxt.framework.rbac.menu.service.MenuService;

@Controller
@RequestMapping("/sys/menu")
public class MenuController {
	@Autowired
	private MenuService menuService;
	@GetMapping("/index")
	public String index() {
		return "menu/index";
	}

	@GetMapping("/tree")
	@ResponseBody
	public Map<String, Object> getMenuTree() {
		return this.menuService.getTreeMap();
	}

	@GetMapping("/add/{id}/{name}")
	public String add(@PathVariable Integer id, @PathVariable String name, Model model) {
		model.addAttribute("parent_id", id);
		model.addAttribute("parent_name", name);
		return "menu/add";
	}
}
